/* $Id: VBoxMPVModes.h $ */
/** @file
 * VBox WDDM Miniport driver
 */

/*
 * Copyright (C) 2014-2020 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 */

#ifndef _WDDM_INCLUDE_VBOXMPMODES_H_
#define _WDDM_INCLUDE_VBOXMPMODES_H_

#include "VBoxMPSa.h"

typedef struct VBOX_VMODES
{
    UINT32 cTargets;
    CR_SORTARRAY aTargets[VBOX_VIDEO_MAX_SCREENS];
} VBOX_VMODES;

typedef struct VBOXWDDM_VMODES
{
    VBOX_VMODES Modes;
    /* note that we not use array indices to indentify modes, because indices may change due to element removal */
    UINT64 aTransientResolutions[VBOX_VIDEO_MAX_SCREENS];
    UINT64 aPendingRemoveCurResolutions[VBOX_VIDEO_MAX_SCREENS];
} VBOXWDDM_VMODES;

#define _SVGA_CR_TYPECAST(_Type, _pVal) ((_Type*)((void*)(_pVal)))

DECLINLINE(UINT64) vboxRSize2U64(RTRECTSIZE size) { return *_SVGA_CR_TYPECAST(UINT64, &(size)); }
DECLINLINE(RTRECTSIZE) vboxU642RSize2(UINT64 size) { return *_SVGA_CR_TYPECAST(RTRECTSIZE, &(size)); }

#define CR_RSIZE2U64 vboxRSize2U64
#define CR_U642RSIZE vboxU642RSize2

int VBoxWddmVModesInit(PVBOXMP_DEVEXT pExt, BOOLEAN initialed);
void VBoxWddmVModesCleanup();
void VBoxWddmVModesRemoveAll(PVBOXMP_DEVEXT pExt);
const CR_SORTARRAY* VBoxWddmVModesGet(PVBOXMP_DEVEXT pExt, UINT32 u32Target);
int VBoxWddmVModesRemove(PVBOXMP_DEVEXT pExt, UINT32 u32Target, const RTRECTSIZE *pResolution);
int VBoxWddmVModesAdd(PVBOXMP_DEVEXT pExt, UINT32 u32Target, const RTRECTSIZE *pResolution, BOOLEAN fTrancient);

NTSTATUS VBoxWddmChildStatusReportReconnected(PVBOXMP_DEVEXT pDevExt, UINT32 iChild);
NTSTATUS VBoxWddmChildStatusConnect(PVBOXMP_DEVEXT pDevExt, UINT32 iChild, BOOLEAN fConnect);

#endif
